home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 8309 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: ssc.sas.upenn.edu!modavis
  2. From: modavis@ssc.sas.upenn.edu (Morris A. Davis)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Fahrenheight to Celsius?
  5. Date: 16 Feb 1996 18:46:24 GMT
  6. Organization: University of Pennsylvania
  7. Message-ID: <4g2je0$ags@netnews.upenn.edu>
  8. References: <4fra3q$ddt@newsbf02.news.aol.com> <4fvthq$2bl@newserv.agcs.com> <DMvMCv.KzA@tr.unisys.com>
  9. NNTP-Posting-Host: ssc.sas.upenn.edu
  10. X-Newsreader: TIN [version 1.2 PL2-upenn1.3]
  11.  
  12. Benjamin M. Romer (bmr1@trpo4.tr.unisys.com) wrote:
  13. : okay.. here goes nothing:
  14.  
  15. : #include <iostream.h>
  16.  
  17. : class Celcius;
  18.  
  19. : class Farenheight
  20. : {
  21. : private:
  22. :      double temp;
  23. : public:
  24. :      Farenheight(double tmp)
  25. :      :temp(tmp)
  26. :      {}
  27. :      Celcius operator Celcius()
  28. :      {
  29. :          return Celcius((temp - 32) / 2.5);
  30.  
  31. (5/9) != (1/2.5)
  32.  
  33. OK here's your homework:
  34. 1)  define f=temperature in farenheit
  35. 2)  define c=temperature in celcius
  36.  
  37. If they enter farenheit, convert to celcius by
  38. c=(f-32)*5/9
  39.  
  40. If they enter celcius, convert to farenheit by
  41. f=(9/5)*c + 32  (duh, see above)
  42.  
  43. Please, lets end this thread.  Now I'm sorry I even contributed
  44. And, kid, stop posting your homework questions!
  45.  
  46. Morris Davis
  47.